package cn.iocoder.yudao.module.system.api.dict;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataExtRespDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataExtDO;
import cn.iocoder.yudao.module.system.service.dict.DictDataExtService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class DictDataExtApiImpl implements DictDataExtApi {

    @Resource
    private DictDataExtService dictDataExtService;


    @Override
    public CommonResult<DictDataExtRespDTO> getDictData(String dictType, String value) {
        DictDataExtDO dictData = dictDataExtService.getDictData(dictType, value);
        return success(BeanUtils.toBean(dictData, DictDataExtRespDTO.class));
    }

    @Override
    public CommonResult<DictDataExtRespDTO> parseDictData(String dictType, String label) {
        DictDataExtDO dictData = dictDataExtService.parseDictData(dictType, label);
        return success(BeanUtils.toBean(dictData, DictDataExtRespDTO.class));
    }


}
